from google.appengine.api import users

import string

not_signed_in_template = string.Template('''
<div id='header'><a href="$login_url">Sign in</a></div>
''')

signed_in_template = string.Template('''
<div id='header'>$nickname | <a href="$logout_url">Sign out</a></p></div>
''')

def make_header_html(login_dest_url):
  user = users.get_current_user()
  if user:
    return signed_in_template.substitute(
        nickname=user.nickname(),
        logout_url=users.create_logout_url(login_dest_url))
  else:
    return not_signed_in_template.substitute(
        login_url=users.create_login_url(login_dest_url))

